package jianzhioffer;

// 剑指 Offer 46. 把数字翻译成字符串
public class TranslateNum {

    public int translateNum(int num) {

        String s = String.valueOf(num);
        int[] f = new int[s.length()+1];
        f[0] = 1;
        f[1] = 1;
        for (int i = 2; i <= s.length(); i++) {
            String t = s.substring(i - 2, i);
            if (t.compareTo("10") >= 0 && t.compareTo("25") <= 0) {
                f[i] = f[i - 1] + f[i - 2];
            }else {
                f[i] = f[i-1];
            }
        }
        return f[s.length()];
    }
}
